package org.csu.onlineedubackend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.csu.onlineedubackend.entity.StudentCourseDanmaku;

import java.util.List;

@Mapper
public interface StudentCourseDanmakuMapper extends BaseMapper<StudentCourseDanmaku> {
    
    /**
     * 根据课时ID查询弹幕列表
     * @param lessonId 课时ID
     * @return 弹幕列表
     */
    @Select("SELECT * FROM student_course_danmaku WHERE lesson_id = #{lessonId} AND status = 'normal' ORDER BY time_point ASC")
    List<StudentCourseDanmaku> selectByLessonId(Integer lessonId);
    
    /**
     * 根据课时ID和时间范围查询弹幕列表
     * @param lessonId 课时ID
     * @param startTime 开始时间点（秒）
     * @param endTime 结束时间点（秒）
     * @return 弹幕列表
     */
    @Select("SELECT * FROM student_course_danmaku WHERE lesson_id = #{lessonId} AND time_point >= #{startTime} AND time_point <= #{endTime} AND status = 'normal' ORDER BY time_point ASC")
    List<StudentCourseDanmaku> selectByLessonIdAndTimeRange(Integer lessonId, Integer startTime, Integer endTime);
}